package com.wntms.ft.service.impl;

import com.wntms.ft.dao.IndexDao;
import com.wntms.ft.pojo.FareForm;
import com.wntms.ft.pojo.Index;
import com.wntms.ft.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IndexServiceImpl implements IndexService {

    @Autowired
    private IndexDao indexDao;
    @Override
    public Index selectOrder() {
        Index index = new Index();
        int allOrder = indexDao.findAllOrder();
        int waitSendOrder = indexDao.findWaitSendOrder();
        int transitOrder = indexDao.transitOrder();
        int finishedOrder = indexDao.finishedOrder();
        index.setAllOrder(allOrder);
        index.setWaitSendOrder(waitSendOrder);
        index.setTransitOrder(transitOrder);
        index.setFinishedOrder(finishedOrder);
        return index;
    }

    @Override
    public List<FareForm> findFareTotal() {
        List<FareForm> allFare = indexDao.findAllFare();
        for (FareForm fareForm : allFare) {
            String nameById = indexDao.findNameById(fareForm.getId());
            fareForm.setName(nameById);
        }
        return allFare;
    }
}
